﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
////class Person
////{
////public:
////	// 进⼊校园/图书馆/实验室刷⼆维码等⾝份认证
////	void identity()
////	{
////		cout << "void identity()" << _name << endl;
////	}
////
////	string _name = "张三"; // 姓名
////	string _address; // 地址
////	string _tel; // 电话
////	int _age = 18; // 年龄
////};
////class Student : public Person
////{
////public:
////	// 学习
////	void study()
////	{
////		// ...
////	}
////
////	int _stuid; // 学号
////};
////
////class Teacher : public Person
////{
////public:
////	// 授课
////	void teaching()
////	{
////		//...
////	}
////
////	string title; // 职称
////};
////int main()
////{
////	Student s;
////	Teacher t;
////	Person p;
////	s.identity();
////	t.identity();
////	cout << &(s._name) << endl;
////	cout << &(t._name) << endl;
////	cout << &(p._name) << endl;
////	return 0;
////}
//// Student的_num和Person的_num构成隐藏关系，可以看出这样代码虽然能跑，但是⾮常容易混淆
//
//
//
////class Person
////	 {
//// public:
////	 //默认构造函数
////	 Person(const char* name = "peter")
////		 : _name(name)
////		 {
////		 cout << "Person()" << endl;
////		}
////	 //构造函数
////	 /*Person(const Person& p)
////		 : _name(p._name)
////	 {
////		 cout << "Person(const Person& p)" << endl;
////	 }*/
////	 protected:
////		 string _name; // 姓名
////};
////class Student : public Person
////{
////public:
////	//派生类构造函数
////	//默认的构造函数通常会
////	//1.对于基本类型的成员不做处理
////	//2.自定义成员会调用它的默认构造
////	//3.把继承的基类成员看做一个整体去调用基类的默认构造函数
////	Student(const char* name="ls", int num=19)//缺省值是给参数化列表使用的
////		: Person(name)
////		, _num(num)
////	{
////		cout << "Student()" << endl;
////	}
////protected:
////	int _num; //学号
////};
////int main()
////{
////	Student s1;
////	return 0;
////}
////class A
////{
////public:
////    A() :m_iVal (0) { test(); }
////  virtual void func() { std::cout << m_iVal; }
////  void test() { func(); }
////public:
////    int m_iVal;
////};
////
////
////
////class B : public A
////{
////public:
////
////    B() { test(); }
////    virtual void func()
////    {        ++m_iVal;
////
////        std::cout << m_iVal ;
////
////    }
////
////};
//
//
//class Person
//	 {
// public:
//	 Person(const char* name = "peter")
//		 : _name(name)
//		{
//		 cout << "Person()" << endl;
//	 }
//	 Person(const Person& p)
//		 : _name(p._name)
//	 {
//		 cout << "Person(const Person& p)" << endl;
//	 }
//	 Person& operator=(const Person& p)
//	 {
//		 cout << "Person operator=(const Person& p)" << endl;
//		 if (this != &p)
//			 _name = p._name;
//		 return *this;
//	 }
//	 ~Person()
//	 {
//		 cout << "~Person()" << endl;
//	 }
//	 protected:
//		 string _name; // 姓名
//};
//class Student : public Person
//{
//public:
//	Student(const char* name, int num)
//		: Person(name)
//		, _num(num)
//	{
//		cout << "Student()" << endl;
//	}
//	Student(const Student& s)
//		: Person(s)
//		, _num(s._num)
//	{
//		cout << "Student(const Student& s)" << endl;
//	}
//	//this=s
//	Student& operator = (const Student& s)
//	{
//		cout << "Student& operator= (const Student& s)" << endl;
//		if (this != &s)
//		{
//			// 构成隐藏，所以需要显⽰调⽤
//			Person::operator =(s);
//			_num = s._num;
//		}
//		return *this;
//	}
//	~Student()
//	{
//		cout << "~Student()" << endl;
//	}
//protected:
//	int _num; //学号
//};
//int main()
//{
//	Student s1("jack", 18);
//	Student s2(s1);
//	Student s3("rose", 17);
//	s1 = s3;
//	return 0;
//}
//



class person final
{
protected:
	person()
	{
		cout << "person()" << endl;
	}
};
class teacher :public person
{
	teacher()
	{
		cout << "teacher()" << endl;
	}
};